Package MusicLandscape
Class Date
- java.lang.Object
-
- MusicLandscape.Date
-
- All Implemented Interfaces:
java.lang.Comparable<Date>,ConsoleScanable
public class Date extends java.lang.Object implements java.lang.Comparable<Date>, ConsoleScanable
- Version:
- 234
- Author:
- TeM, JS
- Stage:
- ES04
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDay(int n)voidaddMonth(int i)voidaddYear(int i)intcompareTo(Date d)Compares this date to another date.java.lang.StringdateString()private java.lang.StringdayName(int w)intgetDay()intgetMonth()intgetYear()booleanisLeap()static intjul2lil(int jul)converts Julian Day Number to Lilian Day NumberintjulianDayNumber()static intjulianDayNumber(int y, int m, int d)returns the Julian Day Number for specified Date given as year, month and day (in Gregorian calendar) (for formulas see http://en.wikipedia.org/wiki/Julian_day)static intlil2jul(int lil)converts Lilian Day Number to Julian Day NumberintlilianDayNumber()static intlilianDayNumber(int y, int m, int d)returns the Lilian Date Number for the Date given as year, month, and day (in Grgorian calendar) (for details see http://en.wikipedia.org/wiki/Lilian_date)private java.lang.StringmonthName(int month)private java.lang.StringnumberEnding()java.lang.StringnumericString()booleanscan()Guides the user through a process that allows scanning/modifying an object with a text-based user interface.voidsetJulian(int jul)sets the current Date to the Date given as Julian Day Numberjava.lang.StringtoString()intweekday()Calculates the day of the week this date.
0...SUN 6...SAT
-
-
-
Constructor Detail
-
Date
public Date(Date date)
Copy constructor- Parameters:
date- the date to copy
-
Date
public Date()
-
-
Method Detail
-
getYear
public int getYear()
- Returns:
- the year of this date
-
getDay
public int getDay()
- Returns:
- the day of this date
-
getMonth
public int getMonth()
- Returns:
- the month of this date
-
isLeap
public boolean isLeap()
- Returns:
- true if this date is in a leap year, false otherwise
-
weekday
public int weekday()
Calculates the day of the week this date.
0...SUN 6...SAT- Returns:
- the weekday of this date
-
dateString
public java.lang.String dateString()
- Returns:
- a formatted String representing this date
-
numberEnding
private java.lang.String numberEnding()
- Returns:
- the number ending of a the day of this date
-
monthName
private java.lang.String monthName(int month)
- Parameters:
month- the month for which the English name shall be calculated- Returns:
- the English name of a month
-
dayName
private java.lang.String dayName(int w)
- Parameters:
w- the number of the day (as explained in weekday())- Returns:
- the English name of a day of the week
-
addDay
public void addDay(int n)
- Parameters:
n- the number of days to add to this date
-
addMonth
public void addMonth(int i)
- Parameters:
i- the number of months to add to this date
-
addYear
public void addYear(int i)
- Parameters:
i- the number of year to add to this date
-
julianDayNumber
public static int julianDayNumber(int y, int m, int d)returns the Julian Day Number for specified Date given as year, month and day (in Gregorian calendar) (for formulas see http://en.wikipedia.org/wiki/Julian_day)- Parameters:
y- yearm- monthd- day- Returns:
- the Julian Day Number
-
julianDayNumber
public int julianDayNumber()
- Returns:
- the Julian Day Number for this Date (for formulas see http://en.wikipedia.org/wiki/Julian_day)
-
lil2jul
public static int lil2jul(int lil)
converts Lilian Day Number to Julian Day Number- Parameters:
lil- Lilian day number- Returns:
- the Julian Day Number of the day specified by its Lilian Day Number
-
jul2lil
public static int jul2lil(int jul)
converts Julian Day Number to Lilian Day Number- Parameters:
jul- Julian day number- Returns:
- the Lilian Day Number of the day specified by its Julian Day Number
-
lilianDayNumber
public int lilianDayNumber()
- Returns:
- returns the Lilian Date Number for this Date for details see http://en.wikipedia.org/wiki/Lilian_date
-
lilianDayNumber
public static int lilianDayNumber(int y, int m, int d)returns the Lilian Date Number for the Date given as year, month, and day (in Grgorian calendar) (for details see http://en.wikipedia.org/wiki/Lilian_date)- Parameters:
y- yearm- monthd- day- Returns:
- the Lilian Day Number of the specified date
-
setJulian
public void setJulian(int jul)
sets the current Date to the Date given as Julian Day Number- Parameters:
jul- Julian Day Number
-
numericString
public java.lang.String numericString()
- Returns:
- a formatted String representing this date
-
compareTo
public int compareTo(Date d)
Compares this date to another date.- Specified by:
compareToin interfacejava.lang.Comparable<Date>- Parameters:
d- the date to compare this date to- Returns:
- a measure of the distance between this date and another date
-
scan
public boolean scan()
Description copied from interface:ConsoleScanableGuides the user through a process that allows scanning/modifying an object with a text-based user interface. Implementing classes may choose to provide a cancel mechanism and/or a keep-old-value mechanism. The user interaction is completely left to implementing classes and must be documented there.Documentation should include:
- which fields and in which order they can be modified
- if and how cancellation and keeping old values works
- how illegal inputs are dealt with (message, repeated input of single field or all fields,...)
- Specified by:
scanin interfaceConsoleScanable- Returns:
- true if this date was modified during the operation, false otherwise
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-